package kunsch.bexp;

import java.util.ArrayList;
import java.util.List;

public abstract class Gate extends Expression
{

	private List<Expression> expressions;
	protected String divider;

	public Gate(List<Expression> expressions)
	{
		this.setExpressions(expressions);
		this.divider = "";

	}

	public Gate(Expression... exprs)
	{

		this.divider = "";
		List<Expression> expressions = new ArrayList();
		for (Expression exp : exprs)
		{
			expressions.add(exp);
		}
		setExpressions(expressions);
	}

	@Override
	public String toString()
	{
		String value = "(";
		for (Expression exp : getExpressions())
		{
			value += exp + divider;
		}
		return value.substring(0, value.length() - divider.length()) + ")";

	}

	public List<Expression> getExpressions()
	{
		return expressions;
	}

	public void setExpressions(List<Expression> expressions)
	{
		for (Expression exp : expressions)
		{
			exp.setParent(this);
		}
		this.expressions = expressions;
	}

}
